package com.goodving.guli.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Date;

/**
 * Created by john on 2015/11/20.
 */
public class GuliUser implements Parcelable {
    public int userId;
    public String userName;
    public int roleId;
    public Date createTime;
    public Date updateTime;
    public String loginName;
    public String loginPassword;

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.userId);
        dest.writeString(this.userName);
        dest.writeInt(this.roleId);
        dest.writeLong(createTime != null ? createTime.getTime() : -1);
        dest.writeLong(updateTime != null ? updateTime.getTime() : -1);
        dest.writeString(this.loginName);
        dest.writeString(this.loginPassword);
    }

    public GuliUser() {
    }

    protected GuliUser(Parcel in) {
        this.userId = in.readInt();
        this.userName = in.readString();
        this.roleId = in.readInt();
        long tmpCreateTime = in.readLong();
        this.createTime = tmpCreateTime == -1 ? null : new Date(tmpCreateTime);
        long tmpUpdateTime = in.readLong();
        this.updateTime = tmpUpdateTime == -1 ? null : new Date(tmpUpdateTime);
        this.loginName = in.readString();
        this.loginPassword = in.readString();
    }

    public static final Parcelable.Creator<GuliUser> CREATOR = new Parcelable.Creator<GuliUser>() {
        public GuliUser createFromParcel(Parcel source) {
            return new GuliUser(source);
        }

        public GuliUser[] newArray(int size) {
            return new GuliUser[size];
        }
    };
}
